import * as types from '../actionTypes/todos';

// 处理数据的 reducer
export const todos = (
  state = [{ id: 1, text: '吃饭', done: true }],
  action
) => {
  console.log('todos', state, action);
  switch (action.type) {
    case types.ADD_TODO:
      return [
        ...state,
        { id: action.payload.id, text: action.payload.text, done: false },
      ];

    default:
      return state;
  }
};
